package com.volcreate.guoqing.no4;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static List<String> mySplit(String str, String separator) {
        int sepLen = separator.length(), begin = 0, end;

        List<String> list = new ArrayList<>();
        for (int i = 0; i < str.length(); i++) {
            if (i + sepLen > str.length()) break;
            if (str.substring(i, i + sepLen).equals(separator)) {
                end = i;
                list.add(str.substring(begin, end));
                begin = i + sepLen;
                i += sepLen - 1;
                if (i > str.length()) break;
            }
        }
        list.add(str.substring(begin));
        return list;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();

        int i;
        StringBuilder p = new StringBuilder();
        String connect = "";
        for (i = 0; i < str2.length(); i++) {
            if (str2.charAt(i) == ' ') {
                break;
            }
            p.append(str2.charAt(i));
        }
        connect += str2.substring(i + 1);
        List<String> list = mySplit(str1, p.toString());

        StringBuilder arrayString = new StringBuilder("[");
        StringBuilder connectString = new StringBuilder();
        for (Object s : list) {
            arrayString.append('"').append(s).append("\", ");
        }
        arrayString.delete(arrayString.length() - 2, arrayString.length());
        arrayString.append("]");
        for (Object s : list) {
            connectString.append(s).append(connect);
        }
        connectString.delete(connectString.length() - connect.length(), connectString.length());
        System.out.println(arrayString);
        System.out.println(connectString);
    }
}


